package com.zidian.study.activity;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zidian.student.trucks.R;
import com.zidian.study.bean.EvaluateTeacherBean;
import com.zidian.study.fragment.EvaHotFragment;
import com.zidian.study.fragment.EvaNewFragment;
import com.zidian.study.globa.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by GongCheng on 2016/11/28.
 */

public class EvaMoreActivity extends BaseActivity {

    @Bind(R.id.eva_new_tv)
    TextView evaNewTv;
    @Bind(R.id.eva_hot_tv)
    TextView evaHotTv;
    @Bind(R.id.evaluate_custom_image)
    CircleImageView evaluateCustomImage;
    @Bind(R.id.evaluate_custom_name)
    TextView evaluateCustomName;
    @Bind(R.id.evaluate_custom_class)
    TextView evaluateCustomClass;
    @Bind(R.id.evaluate_custom_count)
    TextView evaluateCustomCount;

    private boolean isFirst = true;
    private EvaluateTeacherBean.DataBean teacherMessage = new EvaluateTeacherBean.DataBean();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_eva);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setTitle("吱");
        ButterKnife.bind(this);
        teacherMessage = (EvaluateTeacherBean.DataBean) getIntent().getSerializableExtra("teacher");
        addFragment(EvaNewFragment.newInstance());
        initView();
    }

    private void initView() {
        evaluateCustomClass.setText(teacherMessage.getCourseName());
        evaluateCustomCount.setText("");
        evaluateCustomName.setText(teacherMessage.getTeacherName());
        Glide.with(this).load(teacherMessage.getHeadPortrait()).placeholder(R.drawable.teacher).into(evaluateCustomImage);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_eva;
    }

    @Override
    protected int getFragmentContentId() {
        return R.id.base_content_view;
    }

    @OnClick(R.id.back_iv)
    public void onBackClick() {
        Log.e("EvaMore", "onBackClick");
        onBackPressed();
    }

    @OnClick(R.id.eva_new_tv)
    public void onEvaNewClick() {
        if (!isFirst) {
            isFirst = true;
            evaNewTv.setBackgroundResource(R.drawable.bg_task_work_tab_select);
            evaNewTv.setTextColor(getResources().getColor(R.color.colorPrimary));
            evaHotTv.setBackgroundResource(R.drawable.bg_task_action_tab);
            evaHotTv.setTextColor(getResources().getColor(R.color.white));
            addFragment(EvaNewFragment.newInstance());
        }
    }

    @OnClick(R.id.eva_hot_tv)
    public void onEvaHotClick() {
        if (isFirst) {
            isFirst = false;
            evaNewTv.setBackgroundResource(R.drawable.bg_task_work_tab);
            evaNewTv.setTextColor(getResources().getColor(R.color.white));
            evaHotTv.setBackgroundResource(R.drawable.bg_task_action_tab_select);
            evaHotTv.setTextColor(getResources().getColor(R.color.colorPrimary));
            addFragment(EvaHotFragment.newInstance());
        }
    }
}
